import request from '@/request'

import type { AxiosRequestConfig } from 'axios'

/**
 * 登录
 * @method POST
 * @param {object} params 
 * @param {string} params.username
 * @param {string} params.password
 * @param {AxiosRequestConfig} options 
 */
export async function loginItem(
  params: {
    username: string
    password: string
  }, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(`${BASE_URL}/${PROJECT}/system/login`, {
    method: 'POST',
    params,
    headers: { 'Content-Type': 'multipart/form-data' },
    ...options,
  })
}

/**
 * 修改登录密码
 * @method POST
 * @param {object} params 
 * @param {string} params.oldPassword 原密码
 * @param {string} params.newPassword 新密码
 * @param {string} params.confirmNewPassword 确认密码
 * @param {AxiosRequestConfig} options 
 */
export async function updatePass(
  data: {
    oldPassword: string
    newPassword: string
    confirmNewPassword: string
  }, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(`${BASE_URL}/${PROJECT}/system/password `, {
    method: 'PUT',
    data,
    ...options,
  })
}

/**
 * 用户注册
 * @method POST
 * @param {object} data 
 * @param {string} data.username
 * @param {string} data.password
 * @param {string} data.nickName
 * @param {string} data.tenantId
 * @param {AxiosRequestConfig} options 
 */
export async function registerItem(
  data: {
    username: string
    password: string
    nickName: string
    tenantId: string
  }, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(`${BASE_URL}/${PROJECT}/public/register`, {
    method: 'POST',
    data,
    ...options,
  })
}

/**
 * 查询当前期
 * @method GET
 * @param {object} params 
 * @param {string} params.tenantId
 * @param {AxiosRequestConfig} options 
 */
export async function periodItem(
  params: { tenantId: string }, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/customer/period/current`, 
    {
      method: 'GET',
      params,
      ...options,
    })
}

/**
 * 查询用户余额
 * @method GET
 * @param {object} params 
 * @param {AxiosRequestConfig} options 
 */
export async function getWalletItem(
  params?: Record<string, any>, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/customer/wallet/balance`, 
    {
      method: 'GET',
      params,
      ...options,
    })
}

/**
 * 查询榜单列表
 * @method GET
 * @param {object} params
 * @param {string} params.tenantId 租户ID
 * @param {string} params.category 分类
 * @param {AxiosRequestConfig} options 
 */
export async function propagandaItem(
  params: {
    tenantId: string
    category: string
  }, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/customer/propaganda/page`, 
    {
      method: 'GET',
      params,
      ...options,
    })
}

/**
 * 查询榜单分类
 * @method GET
 * @param {object} params
 * @param {string} params.tenantId 租户ID
 * @param {string} params.lang 语言
 * @param {AxiosRequestConfig} options 
 */
export async function getCategoryItem(
  params: {
    tenantId: string
    lang: string
  }, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/customer/propaganda/categories`, 
    {
      method: 'GET',
      params,
      ...options,
    })
}

/**
 * 公益榜单 下单
 * @method POST
 * @param {object} data
 * @param {string} data.periodId 期ID
 * @param {string} data.money 金额
 * @param {string} data.bet 推举方向 BLUE ｜ RED
 * @param {string} data.tableId 房间ID  
 * @param {string} data.lang 语言
 * @param {AxiosRequestConfig} options 
 */
export async function createOrder(
  data: {
    periodId: string
    money: string
    bet: string
    tableId: string
    lang: string
  }, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/customer/betOrder/create`, 
    {
      method: 'POST',
      data,
      ...options,
    })
}

/**
 * 余额记录分页接口
 * @method POST
 * @param {object} params
 * @param {AxiosRequestConfig} options 
 */
export async function balanceRecord(
  params: Record<string, any>, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/customer/wallet/balanceRecord/page`, 
    {
      method: 'GET',
      params,
      ...options,
    })
}

/**
 * 交易记录
 * @method POST
 * @param {object} params
 * @param {object} params.winStatus 0 - 未开奖  1 - 赢  2 - 输  3 - 和  4 - 取消
 * @param {AxiosRequestConfig} options 
 */
export async function betOrder(
  params: Record<string, any>, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/customer/betOrder/page`, 
    {
      method: 'GET',
      params,
      ...options,
    })
}

/**
 * 发起提现申请
 * @method POST
 * @param {object} data
 * @param {string} data.payPassword 支付密码
 * @param {string} data.bankName 银行名称
 * @param {string} data.accountNo 卡号
 * @param {string} data.realname 姓名
 * @param {string} data.money 金额
 * @param {string} data.currency 
 * @param {AxiosRequestConfig} options 
 */
export async function createWithdraw(
  data: {
    payPassword: string
    bankName: string
    accountNo: string
    realname: string
    money: string
    currency: string
  }, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/module/withdrawal/client/apply/withdraw`, 
    {
      method: 'POST',
      data,
      ...options,
    })
}

/**
 * 添加默认提现卡
 * @method GET
 * @param {object} data
 * @param {string} data.realname 姓名
 * @param {string} data.bankName 银行名称
 * @param {string} data.accountNo 卡号
 * @param {boolean} data.defaultCard 是否默认卡 true | false
 * @param {AxiosRequestConfig} options 
 */
export async function addBankCard(
  data: {
    realname: string
    bankName: string
    accountNo: string
    defaultCard: boolean
  }, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/module/withdrawal/client/bankCard`, 
    {
      method: 'POST',
      data,
      ...options,
    })
}

/**
 * 删除银行卡
 * @method GET
 * @param {string[]} data
 * @param {AxiosRequestConfig} options 
 */
export async function delBankCard(
  data: string[], 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/module/withdrawal/client/bankCard `, 
    {
      method: 'DELETE',
      data,
      ...options,
    })
}

/**
 * 查询默认提现卡
 * @method GET
 * @param {object} params
 * @param {AxiosRequestConfig} options 
 */
export async function getBankCard(
  params: Record<string, any>, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/module/withdrawal/client/bankCard/default`, 
    {
      method: 'GET',
      params,
      ...options,
    })
}

/**
 * 发起充值申请
 * @method POST
 * @param {object} data
 * @param {object} data.money 金额
 * @param {AxiosRequestConfig} options 
 */
export async function recharge(
  data: Record<'money', any>, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/module/withdrawal/client/apply/recharge`, 
    {
      method: 'POST',
      data,
      ...options,
    })
}

/**
 * 充提记录
 * @method GET
 * @param {object} params
 * @param {AxiosRequestConfig} options 
 */
export async function rechargeRecords(
  params: Record<string, any>, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/module/withdrawal/client/apply/page`, 
    {
      method: 'GET',
      params,
      ...options,
    })
}

/**
 * 设置密码
 * @method PUT
 * @param {object} data
 * @param {string} data.password 密码
 * @param {AxiosRequestConfig} options 
 */
export async function setWalletPass(
  data: Record<'password', string>, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/customer/wallet/password`, 
    {
      method: 'PUT',
      data,
      ...options,
    })
}

/**
 * 查询用户配置
 * @method GET
 * @param {object} params
 * @param {AxiosRequestConfig} options 
 */
export async function getConfig(
  params: Record<string, any>, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/customer/config`, 
    {
      method: 'GET',
      params,
      ...options,
    })
}

/**
 * 捐款
 * @method POST
 * @param {object} data
 * @param {string} data.money 金额
 * @param {AxiosRequestConfig} options 
 */
export async function donate(
  data: {
    money: string
  }, 
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/customer/wallet/donate`, 
    {
      method: 'POST',
      data,
      ...options,
    })
}


/**
 * 捐款数据
 * @method GET
 * @param {object} params
 * @param {AxiosRequestConfig} options 
 */
export async function getDonateData(
  params: Record<string, any>,
  options?: AxiosRequestConfig
): Promise<HTTP.Result<any>> {
  return await request<any, HTTP.Result>(
    `${BASE_URL}/${PROJECT}/customer/wallet/donateData`, 
    {
      method: 'GET',
      params,
      ...options,
    })
}
